package bavaria.hightech.testit.pruefungen.ss08;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.ArrayList;
import java.util.List;

public class ReaderTest {
	
	public static List<GridPoint>readGridPoints(Reader reader){
		BufferedReader br = new BufferedReader(reader);
		List<GridPoint> list = new ArrayList<GridPoint>();
		try {
			while(br.ready()){
				String inputString = br.readLine();
				String[] sa = inputString.split(":");
				list.add(new GridPoint(Integer.parseInt(sa[0]), Integer.parseInt(sa[1])));
			}
			br.close();
			reader.close();
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return list;
	}

	/**
	 * @param args
	 * @throws FileNotFoundException 
	 */
	public static void main(String[] args) throws FileNotFoundException {
		// TODO Auto-generated method stub
		FileReader fr = new FileReader(System.getProperty("user.dir") + "\\src\\bavaria\\hightech\\testit\\pruefungen\\ss08\\file2.txt");
		List<GridPoint> list = readGridPoints(fr);
		System.out.println(list.toString());

		
		

	}

}
